﻿/// <reference path="zhx.js" />
//upload
$(function() {
    $("input[upload]").each(function() {
        $(this).hide();
        var _img = "";
        if ($.trim($(this).val()) != "") {
            _img = $(this).val().substring($(this).val().lastIndexOf('/') + 1);
        }
        $(this).before("<div id=\"div" + $(this).attr("id") + "\" style=\" margin-bottom:5px;\" >" + _img + "</div><a class=\"btA\" href=\"javascript:upLoadFile('" + $(this).attr("upload") + "','" + $(this).attr("id") + "');\">上传通道</a> ");
    });
});
function upLoadFile(type, txtSelect) {
    alert(2);
    showBox("400", '<div style="line-height:30px; padding:5px 0px 10px 0px;"><p>1、选择要上传的文件：</p><span id="upload1"  style="color:#900;">上传通道加载中...</span><p>仅支持 ' + type + ' 格式文件</p><div id="uploadInfo"></div></div>');
    alert(123);
    $("#upload1").uploadify({
        'uploader': toolsPath() + 'flash/uploadify2.swf',
        'cancelImg': toolsPath() + 'images/cancel.png',
        'buttonImg': toolsPath() + 'images/selectFile.png',
        'width': 74,
        'height': 12,
        'script': '/tools/upload/file.aspx',
        'fileExt': type,
        'fileDesc': type,
        'sizeLimit': 1073741824, //1G
        'simUploadLimit': 10,
        'multi': false,
        'auto': true,
        'onSelect': function(a, b, c) { },
        'onComplete': function(a, b, c, d, e) {
            $(".uploadifyQueueItem").remove();
            $("#" + txtSelect).val(c.filePath);
            $("#div" + txtSelect).html(c.name);
            //var _cutcontent1 = '<p>2、上传成功！ <span onclick="closeBox();" style="cursor:pointer; color:#900; text-decoration:underline; font-weight:bolder;">关闭</span></p>';
            //$("#uploadInfo").html(_cutcontent1);
            closeBox();
            $(".uploadifyQueueItem").remove();
        }
    });
}